import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { FactoryClass } from "@/api/backend/index";
import { handleTree, handleRegionIds } from "@/utils/common";

export const useFactoryClass = defineStore(Names.Class, {
  state: () => {
    return {
      single: {},
      originData: {},
    };
  },
  getters: {},
  actions: {
    //班次导入excel文件
    importExcel(data: any) {
      return new Promise((resolve, reject) => {
        _post(FactoryClass + "/import", data, "formData", "")
          .then((res) => {
            console.log("导入excel文件", res);
            resolve(res as any);
          })
          .catch((err) => {
            console.log(err);
          });
      });
    },
    //获取班次数据
    getStationByRole(filter: any) {
      return new Promise((resolve, reject) => {
        _get(FactoryClass + "/list", filter, "json", "")
          .then(async (res: any) => {
            console.log("获取班次数据", res);
            resolve(res);
          })
          .catch((err) => {
            reject(err);
          });
      });
    },
  },
});
